package com.jinzecloud.reportapproval.controller;

import com.jinzecloud.reportapproval.constant.AdminSwaggerTagConst;
import com.jinzecloud.reportapproval.form.RoleMenuUpdateForm;
import com.jinzecloud.reportapproval.service.RoleMenuService;
import com.jinzecloud.reportapproval.utils.R;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 角色的菜单

 */
@RestController
@CrossOrigin
@Api(tags = AdminSwaggerTagConst.System.SYSTEM_ROLE_MENU)
public class RoleMenuController {

    @Resource
    private RoleMenuService roleMenuService;

    @Operation(summary = "更新角色权限")
    @PostMapping("/role/menu/updateRoleMenu")
//    @SaCheckPermission("system:role:menu:update")
    public R updateRoleMenu(@Valid @RequestBody RoleMenuUpdateForm updateDTO) {
        return roleMenuService.updateRoleMenu(updateDTO);
    }

    @Operation(summary = "获取角色关联菜单权限")
    @GetMapping("/role/menu/getRoleSelectedMenu/{roleId}")
    public R getRoleSelectedMenu(@PathVariable Long roleId) {
        return roleMenuService.getRoleSelectedMenu(roleId);
    }
}
